With the appropriate hardware, image compressor components can handle asynchronous compression and decompression of images using the CDBandCompress and CDBandDecompress functions, which are described on CDBandCompress and CDBandDecompress , respectively. Asynchronous refers to the fact that the compression or decompression hardware performs its operations while the Macintosh computer simultaneously continues its activities. For example, the Macintosh can read a movie for the next frame while the current frame is decompressed. The Image Compression Manager ensures that any asynchronous operation in progress is completed before starting the next operation.
If the Image Compression Manager wants the image compressor component to perform an operation asynchronously, then the completionProcRecord field in the compression or decompression parameters structure that the Image Compressor Manager sends to the image compressor component should be set to a nonzero value. If the value is -1, then the component should perform the operation asynchronously, but it does not need to call a completion function. If the value is not nil and not -1, then the component should perform the operation asynchronously, and it should call the completion function when the operation is done. For details on the compression parameters structure, see The Compression Parameters Structure . For more on the decompression parameters structure, see The Decompression Parameters Structure .
To provide synchronization for the Image Compression Manager, an image compressor component provides the CDCodecBusy function (described on CDCodecBusy ). CDCodecBusy should always return 1 if an asynchronous operation is in progress; it should return 0 if there is no asynchronous operation in progress or if the image compressor component does not perform asynchronous operations. If the Image Compression Manager provided a completion function, the image compressor component must call the completion function as well.
If the Image Compression Manager provided a completion function, then the compressor component must call it; otherwise, the memory for that operation may become increasingly stranded in the system and difficult to deallocate.
There are two distinct steps to an asynchronous compression or decompression operation. The first step depends on the source data, and the second step depends on the destination data.
Depending on the design of the hardware used by your image compressor component, the two steps in the asynchronous operations may be independent of each other or tied together. To indicate to the completion function which steps have been completed, you use the codecCompletionSource and CodecCompletionDest flags for the first and second steps, respectively. If both parts of the asynchronous operation are completed together, the image compressor component can call the completion function once with both flags set. The memory used for each part of the operation remains valid and locked while asynchronous operations are in progress. It is the responsibility of image compressor components to make sure that they remain resident in RAM if virtual memory is active (this is only an issue for hardware image compressor components that perform direct memory access).